﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using yiCommerce.Mapper;
using yiCommerce.Models.Shops;
using yiCommerce.Service.Shops;

namespace yiCommerce.Controllers
{
    public class ShopController : Controller
    {

        private IShopService _shopService;

        public ShopController(IShopService shopService)
        {
            _shopService = shopService;
        }

        public ActionResult Index(int shopId)
        {
            var shop = _shopService.GetShopById(shopId);

            var shopModel = new ShopModel()
                {
                    ShopOwner = new ShopOwner()
                        {
                            Id = shop.CustomerId
                        },
                    ShopName =  shop.ShopName,
                    ProductList = ProductMapper.PrepareProductOverviewModels(shop.Products).ToList(),
                };
            ViewBag.Model = shopModel;

            return View();
        }


    }
}
